<template>
  <view class="page tn-safe-area-inset-bottom" :style="{paddingTop: vuex_custom_bar_height + 'px'}">
    <view class="top-bg"></view>
    <dawnBar title="授权"></dawnBar>
    <view class="page-container" style="padding-bottom: 140rpx;">
      <view class="msg-box">
        <image class="msg-box--image" mode="aspectFit" :src="appConfig.companyRespVO.logoText"></image>
      </view>
    </view>

    <!-- loading -->
    <dawnLoading :show="loading"></dawnLoading>

    <!-- 悬浮按钮-->
    <NavBtn></NavBtn>
  </view>
</template>

<script>
import page_mixin from '@/mixins/page_mixin.js'
import {
  toLogin
} from '@/libs/login.js';
import {
  mapGetters
} from "vuex";
const app = getApp();

export default {
  name: 'redirection',
  mixins: [page_mixin],
  computed: mapGetters(['appConfig', 'uid', 'isLogin', 'userInfo', 'patientInfo']),
  data() {
    return {
      loading: false,
      show: false,
      msg: '',
      dawnMsgBox: '',
      redirect_uri: '',
      pname: ''
    }
  },
  onLoad(options) {
    if (!this.isLogin) {
      toLogin();
      return;
    } else {
      if (options.hasOwnProperty('redirect_uri')) {
        this.redirect_uri = options.redirect_uri;
        // 判断 redirect_uri 是否存在参数 ？
        if (options.redirect_uri.indexOf('?') > 0) {
          location.href = this.redirect_uri + "&openid=" + this.userInfo.openid;
        } else {
          location.href = this.redirect_uri + "?openid=" + this.userInfo.openid;
        }
      } else {
        uni.switchTab({
          url: '/main/index/index'
        })
      }
    }
  },
  }
</script>

<style lang="scss" scoped>
.tn-avatar {
  z-index: 0 !important;
}
</style>